package com.red.wine.view;

import com.red.wine.util.BitmapUtil;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class MenuView extends View {
	private int index = 0;
	private Bitmap bitmap;
	private Context context;
	private int rotate;
	public MenuView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	float width, height;

	public MenuView(Context context,Bitmap bitmap, float width, float height, int rotate, int index) {
		super(context);
		this.index = index;
		this.rotate = rotate;
		this.context = context;
		this.bitmap = bitmap;
		this.width = width;
		this.height = height;
	}


	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Bitmap bitmaps =BitmapUtil.rotateBitmap(context, rotate, bitmap);
		switch (index) {
		case 0:
			canvas.drawBitmap(bitmaps, (float)(width/2-bitmaps.getWidth())-3, 5+(float)(height/2-bitmap.getHeight()*2-15), null);
			break;
		case 1:
			canvas.drawBitmap(bitmaps,width/2+(float)(bitmap.getWidth()/2)-5, height/2 - bitmap.getWidth()-5 - bitmap.getHeight()/2-bitmap.getWidth()/2, null);
			break;
		case 2:
			float x_p2 = (float)(bitmaps.getWidth()/(Math.cos(Math.abs(75))));
			canvas.drawBitmap(bitmaps,Math.abs(x_p2)+width/2 -bitmap.getWidth()/2-19 , height/2-19, null);
			break;
		case 3:
			canvas.drawBitmap(bitmaps,  (float)(Math.sin(15)*bitmap.getWidth())+(width/2-bitmap.getWidth()) +10,10+ height/2+bitmap.getHeight()/2, null);
			break;
		case 4:
			canvas.drawBitmap(bitmaps,width/2-bitmap.getWidth()*3/2-25, height/2+bitmap.getWidth()/2-18, null);
			break;
		case 5:
			float x_p5 = (float)(bitmaps.getWidth()/(Math.cos(rotate)));
			float y_p5 = (float)(bitmaps.getWidth()*Math.cos(rotate));
			canvas.drawBitmap(bitmaps, width/2 - Math.abs(x_p5) -14, height/2 - 15 - Math.abs(y_p5), null);
			break;
		default:
			break;
		}
		
	}

}